<template>
	<view class="content">
		<!-- <view class="form-content">
			<view class="form-ctrl">时间范围：</view>
			<picker mode="date" class="form-ctrl" fields="day" :end="end" :value="workTimeStart" @change="bindStart">
				<view class="uni-input">{{workTimeStart}} -</view>
			</picker>
			<picker mode="date" class="form-ctrl" fields="day" :start="workTimeStart" :end="end" :value="workTimeEnd"
				@change="bindEnd">
				<view class="uni-input">{{workTimeEnd}}</view>
			</picker>
			<view class="iconfont icon-gengduo1 arrow"></view>
		</view> -->
		<!-- 县委书记 -->
		<view class="info-block" v-for="(item,index) in infoList" :key="item.id">
			<view style="display: flex;flex-direction: row;justify-content: space-between;">
				<view class="leader">{{item.duties}}：{{item.name}}</view>
				<view @click="infoList[index].expand =!item.expand" class="more"
					v-if="item.project.length>0&&item.project">
					<view class="iconfont icon-shangla" v-if="item.expand==true"></view>
					<view class="iconfont icon-icon_xialaxuanze" v-else-if="item.expand==false"></view>
				</view>
			</view>
			<template v-if="item.project.length>0">
				<view class="search-block" :class="item.expand?'':'fewer'">
					<view class="input-block">
						<input placeholder="请输入搜索关键字" v-model="name" @confirm="search"
							placeholder-style="color:#0059FC;" />
						<view class="iconfont icon-sousuo" @click="search"></view>
					</view>
				</view>
				<view class="info-list" v-for="(item1,index1) in item.project" :key="item1.id"
					:class="item.expand?'':'fewer'">
					<view class="project">{{index1+1}}、{{item1.matterName}}</view>
					<view class="time">开始时间：{{item1.startTime}}</view>
					<view class="time">完成时限：<text v-if="item1.completeTime">{{item1.completeTime}}</text><text
							v-else>暂无</text></view>
					<view class="time" v-if="item1.updateTime">更新时间：{{item1.updateTime}}</view>
					<view class="time" v-else>更新时间：暂无</view>
					<view class="time">责任书记：<text v-if="item1.dutyNameText">{{item1.dutyNameText}}</text><text
							v-else>暂无</text></view>
					<view class="time">责任单位：{{item1.unit}}</view>
					<view @click="infoList[index].project[index1].more =!item1.more" class="time">进展情况:<text
							class="more" v-if="item1.progress.length>0">{{item1.more?'【收起】':'【展开】'}}</text><text
							class="more" v-else style="margin-left: 10rpx;">暂无</text></view>
					<view v-for="(item2,index2) in item1.progress" :key="item2.id" class="one"
						:class="item1.more?'':'fewer'">
						<view class="onedot"></view>
						<view class="oneline"></view>
						<view class="onemain">
							<view class="onemaintitle">{{item2.time}}</view>
							<view class="onemaincon">{{item2.content}}</view>
						</view>
					</view>
				</view>
			</template>
		</view>
		<!-- 县委副书记,县长 -->
		<view class="info-block" v-for="(item,index) in infoList1" :key="item.id">
			<view style="display: flex;flex-direction: row;justify-content: space-between;">
				<view class="leader">{{item.duties}}：{{item.name}}</view>
				<view @click="infoList1[index].expand =!item.expand" class="more"
					v-if="item.project.length>0&&item.project">
					<view class="iconfont icon-shangla" v-if="item.expand==true"></view>
					<view class="iconfont icon-icon_xialaxuanze" v-else-if="item.expand==false"></view>
				</view>
			</view>
			<template v-if="item.project.length>0">
				<view class="search-block" :class="item.expand?'':'fewer'">
					<view class="input-block">
						<input placeholder="请输入搜索关键字" v-model="name1" @confirm="search1"
							placeholder-style="color:#0059FC;" />
						<view class="iconfont icon-sousuo" @click="search1"></view>
					</view>
				</view>
				<view class="info-list" v-for="(item1,index1) in item.project" :key="item1.id"
					:class="item.expand?'':'fewer'">
					<view class="project">{{index1+1}}、{{item1.matterName}}</view>
					<view class="time">开始时间：{{item1.startTime}}</view>
					<view class="time">完成时限：<text v-if="item1.completeTime">{{item1.completeTime}}</text><text
							v-else>暂无</text></view>
					<view class="time" v-if="item1.updateTime">更新时间：{{item1.updateTime}}</view>
					<view class="time" v-else>更新时间：暂无</view>
					<view class="time">责任书记：<text v-if="item1.dutyNameText">{{item1.dutyNameText}}</text><text
							v-else>暂无</text></view>
					<view class="time">责任单位：{{item1.unit}}</view>
					<view @click="infoList1[index].project[index1].more =!item1.more" class="time">进展情况:<text
							class="more" v-if="item1.progress.length>0">{{item1.more?'【收起】':'【展开】'}}</text><text
							class="more" v-else style="margin-left: 10rpx;">暂无</text></view>
					<view v-for="(item2,index2) in item1.progress" :key="item2.id" class="one"
						:class="item1.more?'':'fewer'">
						<view class="onedot"></view>
						<view class="oneline"></view>
						<view class="onemain">
							<view class="onemaintitle">{{item2.time}}</view>
							<view class="onemaincon">{{item2.content}}</view>
						</view>
					</view>
				</view>
			</template>
		</view>
		<!-- 县委副书记 鲁辉-->
		<view class="info-block" v-for="(item,index) in infoList2" :key="item.id">
			<view style="display: flex;flex-direction: row;justify-content: space-between;">
				<view class="leader">{{item.duties}}：{{item.name}}</view>
				<view @click="infoList2[index].expand =!item.expand" class="more"
					v-if="item.project.length>0&&item.project">
					<view class="iconfont icon-shangla" v-if="item.expand==true"></view>
					<view class="iconfont icon-icon_xialaxuanze" v-else-if="item.expand==false"></view>
				</view>
			</view>
			<template v-if="item.project.length>0">
				<view class="search-block" :class="item.expand?'':'fewer'">
					<view class="input-block">
						<input placeholder="请输入搜索关键字" v-model="name2" @confirm="search2"
							placeholder-style="color:#0059FC;" />
						<view class="iconfont icon-sousuo" @click="search2"></view>
					</view>
				</view>
				<view class="info-list" v-for="(item1,index1) in item.project" :key="item1.id"
					:class="item.expand?'':'fewer'">
					<view class="project">{{index1+1}}、{{item1.matterName}}</view>
					<view class="time">开始时间：{{item1.startTime}}</view>
					<view class="time">完成时限：<text v-if="item1.completeTime">{{item1.completeTime}}</text><text
							v-else>暂无</text></view>
					<view class="time" v-if="item1.updateTime">更新时间：{{item1.updateTime}}</view>
					<view class="time" v-else>更新时间：暂无</view>
					<view class="time">责任书记：<text v-if="item1.dutyNameText">{{item1.dutyNameText}}</text><text
							v-else>暂无</text></view>
					<view class="time">责任单位：{{item1.unit}}</view>
					<view @click="infoList2[index].project[index1].more =!item1.more" class="time">进展情况:<text
							class="more" v-if="item1.progress.length>0">{{item1.more?'【收起】':'【展开】'}}</text><text
							class="more" v-else style="margin-left: 10rpx;">暂无</text></view>
					<view v-for="(item2,index2) in item1.progress" :key="item2.id" class="one"
						:class="item1.more?'':'fewer'">
						<view class="onedot"></view>
						<view class="oneline"></view>
						<view class="onemain">
							<view class="onemaintitle">{{item2.time}}</view>
							<view class="onemaincon">{{item2.content}}</view>
						</view>
					</view>
				</view>
			</template>
		</view>
		<!-- 县委副书记 魏嘉-->
		<view class="info-block" v-for="(item,index) in infoList3" :key="item.id">
			<view style="display: flex;flex-direction: row;justify-content: space-between;">
				<view class="leader">{{item.duties}}：{{item.name}}</view>
				<view @click="infoList3[index].expand =!item.expand" class="more"
					v-if="item.project.length>0&&item.project">
					<view class="iconfont icon-shangla" v-if="item.expand==true"></view>
					<view class="iconfont icon-icon_xialaxuanze" v-else-if="item.expand==false"></view>
				</view>
			</view>
			<template v-if="item.project.length>0">
				<view class="search-block" :class="item.expand?'':'fewer'">
					<view class="input-block">
						<input placeholder="请输入搜索关键字" v-model="name3" @confirm="search3"
							placeholder-style="color:#0059FC;" />
						<view class="iconfont icon-sousuo" @click="search3"></view>
					</view>
				</view>
				<view class="info-list" v-for="(item1,index1) in item.project" :key="item1.id"
					:class="item.expand?'':'fewer'">
					<view class="project">{{index1+1}}、{{item1.matterName}}</view>
					<view class="time">开始时间：{{item1.startTime}}</view>
					<view class="time">完成时限：<text v-if="item1.completeTime">{{item1.completeTime}}</text><text
							v-else>暂无</text></view>
					<view class="time" v-if="item1.updateTime">更新时间：{{item1.updateTime}}</view>
					<view class="time" v-else>更新时间：暂无</view>
					<view class="time">责任书记：<text v-if="item1.dutyNameText">{{item1.dutyNameText}}</text><text
							v-else>暂无</text></view>
					<view class="time">责任单位：{{item1.unit}}</view>
					<view @click="infoList3[index].project[index1].more =!item1.more" class="time">进展情况:<text
							class="more" v-if="item1.progress.length>0">{{item1.more?'【收起】':'【展开】'}}</text><text
							class="more" v-else style="margin-left: 10rpx;">暂无</text></view>
					<view v-for="(item2,index2) in item1.progress" :key="item2.id" class="one"
						:class="item1.more?'':'fewer'">
						<view class="onedot"></view>
						<view class="oneline"></view>
						<view class="onemain">
							<view class="onemaintitle">{{item2.time}}</view>
							<view class="onemaincon">{{item2.content}}</view>
						</view>
					</view>
				</view>
			</template>
		</view>
		<!-- 县委常委 韩卫忠-->
		<view class="info-block" v-for="(item,index) in infoList4" :key="item.id">
			<view style="display: flex;flex-direction: row;justify-content: space-between;">
				<view class="leader">{{item.duties}}：{{item.name}}</view>
				<view @click="infoList4[index].expand =!item.expand" class="more"
					v-if="item.project.length>0&&item.project">
					<view class="iconfont icon-shangla" v-if="item.expand==true"></view>
					<view class="iconfont icon-icon_xialaxuanze" v-else-if="item.expand==false"></view>
				</view>
			</view>
			<template v-if="item.project.length>0">
				<view class="search-block" :class="item.expand?'':'fewer'">
					<view class="input-block">
						<input placeholder="请输入搜索关键字" v-model="name4" @confirm="search4"
							placeholder-style="color:#0059FC;" />
						<view class="iconfont icon-sousuo" @click="search4"></view>
					</view>
				</view>
				<view class="info-list" v-for="(item1,index1) in item.project" :key="item1.id"
					:class="item.expand?'':'fewer'">
					<view class="project">{{index1+1}}、{{item1.matterName}}</view>
					<view class="time">开始时间：{{item1.startTime}}</view>
					<view class="time">完成时限：<text v-if="item1.completeTime">{{item1.completeTime}}</text><text
							v-else>暂无</text></view>
					<view class="time" v-if="item1.updateTime">更新时间：{{item1.updateTime}}</view>
					<view class="time" v-else>更新时间：暂无</view>
					<view class="time">责任书记：<text v-if="item1.dutyNameText">{{item1.dutyNameText}}</text><text
							v-else>暂无</text></view>
					<view class="time">责任单位：{{item1.unit}}</view>
					<view @click="infoList4[index].project[index1].more =!item1.more" class="time">进展情况:<text
							class="more" v-if="item1.progress.length>0">{{item1.more?'【收起】':'【展开】'}}</text><text
							class="more" v-else style="margin-left: 10rpx;">暂无</text></view>
					<view v-for="(item2,index2) in item1.progress" :key="item2.id" class="one"
						:class="item1.more?'':'fewer'">
						<view class="onedot"></view>
						<view class="oneline"></view>
						<view class="onemain">
							<view class="onemaintitle">{{item2.time}}</view>
							<view class="onemaincon">{{item2.content}}</view>
						</view>
					</view>
				</view>
			</template>
		</view>
		<view class="info-block1">
			<template v-if="list.length>0">
				<view class="info-item" v-for="(item,index) in list" :key="item.id"
					@click="navigate('/pages/supervise/secretary-list?id='+item.id)">
					<view class="name-block">
						<view class="name">{{item.name}}</view>
						<view class="iconfont icon-youjiantou"></view>
					</view>
					<view class="title-item">
						<view class="name" v-if="item.list">{{item.list.duties}}:{{item.list.name}}</view>
					</view>
					<view class="time-item" v-if="item.list">
						<view v-for="(item1,index1) in item.list.report" :key="item1.id" class="one">
							<view class="onedot"></view>
							<view class="oneline"></view>
							<view class="onemain">
								<view style="display: flex;flex-direction: row;align-items: center;">
									<view class="onemaintitle">{{item1.createTime}}</view>
									<view class="onemaintitle" v-if="item1.time==1" style="margin-left: 15rpx;">上午
									</view>
									<view class="onemaintitle" v-else-if="item1.time==2" style="margin-left: 15rpx;">下午
									</view>
									<view class="onemaintitle" style="margin-left: 15rpx;" v-if="item1.location">
										{{item1.location}}
									</view>
								</view>
								<view class="onemaincon">{{item1.report}}</view>
							</view>
						</view>
					</view>
				</view>
			</template>
		</view>
	</view>
</template>

<script>
	import {
		getListApi,
		getSelectListApi
	} from '@/api/supervise.js'
	import {
		getCurrentTime,
		getPickerIndex
	} from '@/util/util';
	export default {
		data() {
			return {
				infoList: [],
				infoList1: [],
				infoList2: [],
				infoList3: [],
				infoList4: [],
				name: '',
				end: getCurrentTime('d'),
				workTimeStart: '开始日期',
				workTimeEnd: '结束日期',
				list: [],
				name1: '',
				name2: '',
				name3: '',
				name4: '',
			}
		},
		methods: {
			search() {
				this.getList()
			},
			search1() {
				this.getList1()
			},
			search2() {
				this.getList2()
			},
			search3() {
				this.getList3()
			},
			search4() {
				this.getList4()
			},

			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			getNewList() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getSelectListApi({
					name: this.name
				}).then(res => {
					uni.hideLoading()
					this.list = res.list || []
				}).catch(() => {
					uni.hideLoading()
				})
			},
			bindStart(e) {
				this.workTimeStart = e.detail.value
				if (this.workTimeEnd != '结束日期') {
					this.getList()
				}
			},
			bindEnd(e) {
				this.workTimeEnd = e.detail.value
				if (this.workTimeStart != '开始日期') {
					this.getList()
				}
			},
			getList() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getListApi({
					name: this.name,
					type: 1,
					startTime: this.workTimeStart == '开始日期' ? '' : this.workTimeStart,
					endTime: this.workTimeEnd == '结束日期' ? '' : this.workTimeEnd,
					dutiesId: 8
				}).then(res => {
					uni.hideLoading()
					let list = res.list || [];
					list.forEach((item, index) => {
						if (this.name != '') {
							item.expand = true;
						} else
							item.expand = false;
						if (item.project) {
							item.project.forEach((item1, index1) => {
								item1.more = false;
							})
						} else
							return false
					})
					this.infoList = list
				}).catch(() => {
					uni.hideLoading()
				})
			},
			getList1() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getListApi({
					name: this.name1,
					type: 1,
					startTime: this.workTimeStart == '开始日期' ? '' : this.workTimeStart,
					endTime: this.workTimeEnd == '结束日期' ? '' : this.workTimeEnd,
					dutiesId: 9
				}).then(res => {
					uni.hideLoading()
					let list = res.list || [];
					list.forEach((item, index) => {
						if (this.name1 != '') {
							item.expand = true;
						} else
							item.expand = false;
						if (item.project) {
							item.project.forEach((item1, index1) => {
								item1.more = false;
							})
						} else
							return false
					})
					this.infoList1 = list
				}).catch(() => {
					uni.hideLoading()
				})
			},
			getList2() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getListApi({
					name: this.name2,
					type: 1,
					startTime: this.workTimeStart == '开始日期' ? '' : this.workTimeStart,
					endTime: this.workTimeEnd == '结束日期' ? '' : this.workTimeEnd,
					dutiesId: 10
				}).then(res => {
					uni.hideLoading()
					let list = res.list || [];
					list.forEach((item, index) => {
						if (this.name2 != '') {
							item.expand = true;
						} else
							item.expand = false;
						if (item.project) {
							item.project.forEach((item1, index1) => {
								item1.more = false;
							})
						} else
							return false
					})
					this.infoList2 = list
				}).catch(() => {
					uni.hideLoading()
				})
			},
			getList3() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getListApi({
					name: this.name3,
					type: 1,
					startTime: this.workTimeStart == '开始日期' ? '' : this.workTimeStart,
					endTime: this.workTimeEnd == '结束日期' ? '' : this.workTimeEnd,
					dutiesId: 11
				}).then(res => {
					uni.hideLoading()
					let list = res.list || [];
					list.forEach((item, index) => {
						if (this.name3 != '') {
							item.expand = true;
						} else
							item.expand = false;
						if (item.project) {
							item.project.forEach((item1, index1) => {
								item1.more = false;
							})
						} else
							return false
					})
					this.infoList3 = list
				}).catch(() => {
					uni.hideLoading()
				})
			},
			getList4() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getListApi({
					name: this.name4,
					type: 1,
					startTime: this.workTimeStart == '开始日期' ? '' : this.workTimeStart,
					endTime: this.workTimeEnd == '结束日期' ? '' : this.workTimeEnd,
					dutiesId: 12
				}).then(res => {
					uni.hideLoading()
					let list = res.list || [];
					list.forEach((item, index) => {
						if (this.name4 != '') {
							item.expand = true;
						} else
							item.expand = false;
						if (item.project) {
							item.project.forEach((item1, index1) => {
								item1.more = false;
							})
						} else
							return false
					})
					this.infoList4 = list
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		onLoad() {
			this.getList()
			this.getList1()
			this.getList2()
			this.getList3()
			this.getList4()
			//this.getNewList()
		}
	}
</script>

<style lang="scss">
	.content {
		background: #f5f5f5;
		padding: 30rpx;
		min-height: 100vh;

		.form-content {
			display: flex;
			flex-direction: row;
			justify-content: center;
			margin-bottom: 20rpx;

			.form-ctrl {
				margin-left: 10rpx;
				font-size: 30rpx;
				color: #999;
			}
		}

		.search-block.fewer {
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 1;
			overflow: hidden;
			display: none;
		}

		.search-block {
			position: relative;
			width: 100%;
			height: 60rpx;
			//padding: 0 30rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-top: 30rpx;

			.input-block {
				width: 100%;
				display: flex;
				flex-direction: row;
				align-items: center;
				border: 1px solid #808080;
				border-radius: 40rpx;
				padding: 0 10rpx;
				height: 60rpx;

				.iconfont {
					flex-grow: 0;
					color: #808080;
					margin: 0 10rpx;
				}

				input {
					flex-grow: 1;
					font-size: 28rpx;
					color: #808080;
					margin: 0 10rpx;
				}
			}
		}

		.info-block {
			min-height: 140rpx;
			padding: 30rpx;
			background: #fff;
			border-radius: 20rpx;
			box-shadow: 0 0 10px 0 #dedede;
			margin-bottom: 30rpx;
			height: auto;
			display: flex;
			flex-direction: column;
			justify-content: center;


			.leader {
				//width: calc(100% - 130rpx);
				font-size: 32rpx;
				font-weight: bold;
			}

			.more {
				color: $uni-color-primary;
				font-size: 30rpx;

				.iconfont {
					font-size: 30rpx;
					color: #000;
				}
			}

			.info-list.fewer {
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 1;
				overflow: hidden;
				display: none;
			}

			.info-list {
				background: #f5f5f5;
				padding: 20rpx;
				margin-top: 30rpx;
				border-radius: 20rpx;

				.project {
					font-size: 30rpx;
					font-weight: bold;
					margin-bottom: 30rpx;
					margin-top: 10rpx;
				}

				.time {
					font-size: 30rpx;
					margin-bottom: 30rpx;

					.more {
						color: $uni-color-primary;
						font-size: 30rpx;
					}
				}

				.one.fewer {
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
					overflow: hidden;
					display: none;
				}

				.one {
					position: relative;
					padding-bottom: 10rpx;

					.onedot {
						left: -2rpx;
						width: 24rpx;
						height: 24rpx;
						position: absolute;
						//background-color: #4C7FE2;
						border: 1px solid #4C7FE2;
						border-radius: 50%;
						display: flex;
						justify-content: center;
						align-items: center;
						z-index: 1;
					}

					.oneline {
						position: absolute;
						left: 10rpx;
						height: calc(100% - 24rpx);
						border-left: 1px solid #1254F1;
						margin-top: 24rpx;
					}

					.onemain {
						position: relative;
						padding-left: 56rpx;
						top: -6rpx;
					}

					.onemaintitle {
						margin-bottom: 16rpx;
						padding-top: 8rpx;
						line-height: 1;
						font-size: 28rpx;
						color: #303133;
					}

					.onemaincon {
						color: #303133;
						background-color: #DFE8F9;
						padding: 20rpx;
						font-size: 28rpx;
						line-height: 60rpx;
					}
				}
			}
		}

		.info-block1 {
			display: flex;
			flex-direction: column;
			height: auto;
			position: relative;

			.info-item {
				min-height: 140rpx;
				height: auto;
				box-shadow: 0 0 10px 0 #dedede;
				background: #fff;
				display: flex;
				flex-direction: column;
				justify-content: center;
				border-radius: 20rpx;
				padding: 30rpx;
				margin-bottom: 30rpx;

				.name-block {
					width: 100%;
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					align-items: center;

					.name {
						font-weight: bold;
						font-size: 34rpx;
					}

					.iconfont {
						color: #CBCBCB;
					}
				}

				.title-item {
					width: 100%;
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					align-items: center;
					margin-top: 20rpx;

					.name {
						width: 100%;
						font-weight: bold;
						font-size: 30rpx;
					}

					.time {
						font-size: 28rpx;
						color: $uni-color-primary;
					}
				}


				.time-item.fewer {
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
					overflow: hidden;
					display: none;
				}

				.time-item {
					background: #F8F8F8;
					margin-top: 20rpx;
					padding: 20rpx;
					border-radius: 20rpx;

					.one {
						position: relative;
						padding-bottom: 10rpx;

						.onedot {
							left: -2rpx;
							width: 24rpx;
							height: 24rpx;
							position: absolute;
							//background-color: #4C7FE2;
							border: 1px solid #4C7FE2;
							border-radius: 50%;
							display: flex;
							justify-content: center;
							align-items: center;
							z-index: 1;
						}

						.oneline {
							position: absolute;
							left: 10rpx;
							height: calc(100% - 24rpx);
							border-left: 1px solid #1254F1;
							margin-top: 24rpx;
						}

						.onemain {
							position: relative;
							padding-left: 56rpx;
							top: -6rpx;
						}

						.onemaintitle {
							margin-bottom: 16rpx;
							padding-top: 8rpx;
							line-height: 1;
							font-size: 28rpx;
							color: #303133;
						}

						.onemaincon {
							color: #303133;
							background-color: #DFE8F9;
							padding: 20rpx;
							font-size: 28rpx;
							line-height: 60rpx;
						}
					}
				}
			}
		}
	}
</style>